package com.wencun.cunpicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wencun.cunpicturebackend.model.dto.picture.PictureEditRequest;
import com.wencun.cunpicturebackend.model.dto.picture.PictureQueryRequest;
import com.wencun.cunpicturebackend.model.dto.picture.PictureReviewRequest;
import com.wencun.cunpicturebackend.model.dto.picture.PictureUploadRequest;
import com.wencun.cunpicturebackend.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wencun.cunpicturebackend.model.entity.User;
import com.wencun.cunpicturebackend.model.vo.PictureVO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Queue;

/**
 * @author 温存
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-08-23 23:50:20
 */
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     *
     * @param multipartFile
     * @param pictureUploadRequest
     * @param loginUser
     * @return PictureVO
     * @time 2025-08-24 15:24
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 获取图片 VO
     *
     * @param picture
     * @param request
     * @return PictureVO
     * @time 2025-08-24 19:54
     */
    PictureVO getPictureVO(Picture picture);

    /**
     * 校验图片是否合法
     *
     * @param picture
     * @time 2025-08-24 20:55
     */
    void validPicture(Picture picture);

    /**
     * 分页获取图片封装
     *
     * @param picturePage
     * @param request
     * @return Page<PictureVO>
     * @time 2025-08-24 20:26
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 获取查询包装类
     *
     * @param pictureQueryRequest
     * @return QueryWrapper<Picture>
     * @time 2025-08-24 15:24
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 图片审核
     *
     * @param pictureReviewRequest
     * @param loginUser
     * @time 2025-08-28 20:18
     */

    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充审核参数
     *
     * @param picture
     * @param loginUser
     * @time 2025-08-28 20:31
     */
    void fillReviewParams(Picture picture, User loginUser);

    void checkPictureAuth(User loginUser, Picture picture);

    void deletePicture(long pictureId, User loginUser);

    @Async
    void cleanPictureFile(Picture oldPicture);

    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);
}
